package com.ftg.learn.mapper;

import com.ftg.learn.dao.Danpin;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
@Mapper
public interface DanpinMapper {

    @Select("select * from mingxingdanpin where name like ifnull(concat(#{arg2},'%'),name) limit #{arg0},#{arg1}")
    public List<Danpin> select(int begin, int limit, String name);

    @Select("select * from mingxingdanpin")
    List<Danpin> showall();

    @Select("select count(*) from mingxingdanpin where name like ifnull(concat(#{arg2},'%'),name)")
    int geleteDanpin(String name);

    @Delete("delete from mingxingdanpin where id=#{id}")
    public int delete(String id);
    @Update("update mingxingdanpin set name=#{name},price=#{price},picture=#{picture},remark=#{remark},count=#{count},href=#{href} where id=#{id}")
    int update(Danpin danpin);
    @Insert("insert into mingxingdanpin(id,name,price,picture,remark,count,href) values(#{id},#{name},#{price},#{picture},#{remark},#{count},#{href})")
    public int add(Danpin danpin);

    @Select("select * from mingxingdanpin")
    List<Danpin> selectpicture();
}
